package com.woniuedu.search.controller;


import com.woniuedu.commonutils.R;
import com.woniuedu.search.entity.Teacher;
import com.woniuedu.search.serviec.TeacherService;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author yuankaiqiang
 * @since 2022-04-19
 */
@RestController
@RequestMapping("/search")
public class TeacherController {
    @Resource(name = "teacher")
    private TeacherService teacherService;

    //查询所有
    @GetMapping("/teacher/{name}/{pagenum}/{size}")
    @ApiOperation("es 教授查询")
    public R all(@PathVariable(required = false) String name,
                 @PathVariable(required = false)Integer pagenum,
                 @PathVariable(required = false)Integer size){
        //分页对象
        Pageable pageable = PageRequest.of(pagenum, size);
        //查询
        Page<Teacher> page = teacherService.findByAll(name,pageable);
       return R.ok().data("teacher",page);
    }

}
